package com.phospherus.flow.repository

import com.phospherus.common.repository.BaseRepository
import com.phospherus.flow.entity.FlowNode
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param

/**
 * @author songjinlong
 * @version 1.0
 * @since 2017/11/10
 */
interface FlowNodeRepository : BaseRepository<FlowNode, Long> {
    @Query(value = "select fn.* from flow_node_ref fnr,flow_node fn where fnr.p_flow_node_id= :nodeId and fn.id=fnr.c_flow_node_id", nativeQuery = true)
    fun getChildrenNodes(@Param("nodeId") nodeId: Long): List<FlowNode>

    @Query(value = "select * from flow_node where flow_id= :flowId and node_type=0", nativeQuery = true)
    fun getStartNodeByFlowId(@Param("flowId") flowId: Long): FlowNode
}